DECLARE @Taskid INT = 2456868, @formatlen INT = 5
SELECT REPLICATE(
           '0', CASE 
                     WHEN LEN (@Taskid) <= @formatlen THEN @formatlen -LEN (@Taskid)
                     ELSE 0
                END
       ) + CAST (@taskid AS VARCHAR)
       
